import {listIdc} from "@/api/cmdb/idc";

const idc = {
  state: {
    idcs: [],
    idcTotal: '',
  },

  mutations: {
    SET_IDC: (state, response) => {
      state.idcs = response.rows
      state.idcTotal = response.total
      // localStorage.setItem('idcs',JSON.stringify(state.idcs))
      // localStorage.setItem('idcTotal',state.idcTotal)
    },
  },

  actions: {
    /** 查询idc列表列表 */
    GetIdcList({ commit ,state}) {
      listIdc().then(response => {
        commit('SET_IDC',response)
      });
      //下面是存localstorage的逻辑
      // let idcs;
      // idcs=localStorage.getItem('idcs')
      // if(idcs){
      //   //console.log("ids在localStorage中存在",idcs)
      //   idcs=JSON.parse(idcs)
      //   state.idcs = idcs
      //   state.idcTotal = idcs.length
      // }else{
      //   //console.log("idc.js.GetIdcList","store没有idc,需要去请求")
      //   listIdc().then(response => {
      //     commit('SET_IDC',response)
      //   });
      // }
    },
  }
}

export default idc
